// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({env: 'test-qch4n'})
const db = cloud.database({env: 'test-qch4n'})
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const { location, fileids, dec, address } = event
  const timestamp = new Date().getTime()
  return await db.collection('warnList').add({
    data: {
      _openid: wxContext.OPENID,
      address: address,
      dec: dec,
      location: location,
      fileids: fileids,
      edittime: timestamp,
      status: 0
    }
  })
}